package com.platform.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.platform.comm.web.results.TreeNode;
import lombok.Getter;
import lombok.Setter;

/**
 * @author qy
 * @date Created in 2020/7/16
 **/
@Setter
@Getter
public class ConfTypeTreeNode extends TreeNode {
    private String parentId;
    private Integer lock;
    private Integer sortNum;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private ConfTypeTreeData data;

    public static ConfTypeTreeNode of(String id, String code, String text, String parentId, Integer typeLevel,
                                      String desc, String sortNum, String routeCode, Integer lock) {
        ConfTypeTreeNode treeNode = new ConfTypeTreeNode();
        ConfTypeTreeData confTypeTreeData = new ConfTypeTreeData();
        treeNode.setId(id);
        treeNode.setCode(code);
        treeNode.setText(text);
        treeNode.setLock(lock);
        treeNode.setParentId(parentId);
        treeNode.setSortNum(Integer.parseInt(sortNum));
        confTypeTreeData.setParentId(parentId);
        confTypeTreeData.setTypeLevel(typeLevel);
        confTypeTreeData.setDesc(desc);
        confTypeTreeData.setTypeName(text);
        confTypeTreeData.setTypeCode(code);
        confTypeTreeData.setSortNum(sortNum);
        confTypeTreeData.setRouteCode(routeCode);
        treeNode.setData(confTypeTreeData);
        return treeNode;
    }

    public static ConfTypeTreeNode of(String id, String code, String text, String parentId) {
        ConfTypeTreeNode treeNode = new ConfTypeTreeNode();
        treeNode.setId(id);
        treeNode.setCode(code);
        treeNode.setText(text);
        treeNode.setParentId(parentId);
        return treeNode;
    }
}
